﻿<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%option explicit%>
<%
Dim RZ_IN
RZ_IN=1
%>
<!--#include file="../conn.inc.asp" -->
<!--#include file="admin_inc/admin.function.asp" -->
<!--#include file="admin_inc/admin.sqlfunction.asp" -->
<!--#include file="../asp/articleshow.asp" -->
<!--#include file="../asp/productshow.asp" -->
<!--#include file="../asp/photoshow.asp" -->
<!--#include file="../asp/jobshow.asp" -->

<%
'作者：山林客（ah_bill）
'博客：http://ruizhinet.blog.163.com
'网站：http://www.ruizhinet.cn
'本信息不会影响您网站的正常访问，请保留
checkadmin(1)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>生成记录页</title>
<link type="text/css" href="style/style.css" rel="stylesheet" rev="stylesheet"/>
</head>
<body style="margin-left:50px;margin-top:0px;">
<%
Dim proc,typeid,id,i,sql,rs,path,tablename,url,currentid,timearr,tmptime,lasttime,rcount,num,static_path,updatetype
proc=Trim(request.querystring("proc"))
path=Trim(request.querystring("path"))
static_path=Replace(path,",","-")
typeid=Trim(request.querystring("typeid"))
id=Trim(request.querystring("id"))
i=Trim(request.querystring("i"))
tmptime=Trim(request.querystring("time"))
num=Trim(request.querystring("num"))
updatetype=Trim(request.querystring("updatetype"))
timearr=Split(tmptime,"-")
If IsArray(timearr) And UBound(timearr)=5 Then 
lasttime=timearr(0)&"-"&timearr(1)&"-"&timearr(2)&" "&timearr(3)&":"&timearr(4)&":"&timearr(5)
Else
response.write("<span style=""color:blue;"">时间参数错误</span>")
response.End 
End If 

If i="" Then
	i=0
End If 
If id="" Then 
id=0
Else
id=CInt(id)
End If 
If num="" Then
num=0
End If 
If updatetype="" Then
updatetype=0
End If 
currentid=MakeRecord(proc,id,typeid,lasttime)
If currentid=0 Then 
	response.write("<span style=""color:blue;"">成功生成个"&num&"个内容显示网页</span>")
%>
<script type="text/javascript">
<!--
	parent.document.getElementById("mon").value="type<%=typeid%>done";
//-->
</script>
<%
	response.End 
End If 
Function MakeRecord(proc,id,typeid,lasttime)
	Call CreateFolders(GetPath(RZ_HTML_PATH&"/"&proc&"0/t"&static_path))
	Call CreateFolders(GetPath(RZ_HTML_PATH&"/"&proc&"1/t"&static_path))
	Select Case proc
	Case RZ_PRE_ARTICLE_SHOW:
		tablename="c_article"
	Case RZ_PRE_PRODUCT_SHOW:
		tablename="c_product"
	Case RZ_PRE_PHOTO_SHOW:
		tablename="c_photo"
	Case RZ_PRE_JOB_SHOW:
		tablename="c_job"
	End Select 
	Dim rs,sql,theid,per,filepath
	per=20
	Set rs = Server.CreateObject("ADODB.Recordset")
	If updatetype=1 Then 
	sql = "select top "&per&" path,specialid,id,lang from "&tablename&" where typeid="&typeid&" and visible=1 and id>"&id&" order by id"
	Else 
	sql = "select top "&per&" path,specialid,id,lang from "&tablename&" where typeid="&typeid&" and visible=1 and  modifytime>#"&lasttime&"# and id>"&id&" order by id"
	End If 
	rs.open sql,conn,1,1
	If  Not rs.eof Then
		rcount=rs.recordcount
		Do While Not rs.eof
		Call ChangeStatic(1,rs("lang"))
		If rs("specialid")>0 Then 
			S_RZPARAM.QueryString=proc&rs("lang")&"-"&path&"s"&rs("specialid")&"c"&rs("id")&".html"
			filepath=GetPath(RZ_HTML_PATH&"/"&proc&rs("lang")&"/t"&static_path&"/s"&rs("specialid")&"c"&rs("id")&".html")
		Else 
			S_RZPARAM.QueryString=proc&rs("lang")&"-"&path&"c"&rs("id")&".html"
			filepath=GetPath(RZ_HTML_PATH&"/"&proc&rs("lang")&"/t"&static_path&"/c"&rs("id")&".html")
		End If 
		S_RZPARAM.Generate()
		
		S_HTMLMBUFFER=""
		S_TEMPLATE=""
		Select Case proc
		Case RZ_PRE_ARTICLE_SHOW:
			Call ArticleShow(1)
		Case RZ_PRE_PRODUCT_SHOW:
			Call ProductShow(1)
		Case RZ_PRE_PHOTO_SHOW:
			Call PhotoShow(1)
		Case RZ_PRE_JOB_SHOW:
			Call JobShow(1)
		End Select 
		Call SaveFile(filepath,S_HTMLMBUFFER)
		theid=rs("id")
		rs.movenext
		Loop
		num=(i*per)+rcount
		response.write("<span style='color:blue;'>正在生成第<span style='color:red'><b>"&num&"</b></span>个网页……")
		i=i+1
		url="?proc="&proc&"&typeid="&typeid&"&path="&path&"&id="&theid&"&i="&i&"&num="&num&"&time="&tmptime&"&updatetype="&updatetype
		response.write("<meta http-equiv='refresh' content='2;url="&url&"'>")
		response.write("<a href='"&url&"'>如果没有自动跳转，请点击这里</a>")
		MakeRecord=theid
	Else
		MakeRecord=0
	End If
	rs.close
	Set rs=Nothing 
End Function 
%>
</body>
</html>